package test.rest;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/Factorial")
public class Factorial {
	
	@GET
	@Produces(MediaType.TEXT_HTML)
    public String factorial(@QueryParam("base") long base) {
        return "<h1>" + Long.toString($factorial(base)) + "</h1>";
    }

    long $factorial(long base) {
        if (base >= 1) {
            return $factorial(base - 1) * base;
        }
        return 1;
    }
}
